package edu.usc.libtalk.utils;

import android.graphics.Color;

public class SeatObject {
	private int seatID = 0;
	private float zoomLevel = 1f;
	private Color c; // unique color for this seat when occupied
	public float[] range = new float[8];
	public boolean isActive = false;
	
	public SeatObject(int id, float z, float[] r) {
		seatID = id;
		zoomLevel = z;
		range[0] = r[0]; // x
		range[1] = r[1]; // y
		range[2] = r[2]; // x
		range[3] = r[3]; // y
		range[4] = r[4];
		range[5] = r[5];
		range[6] = r[6];
		range[7] = r[7];
	}
	
	public void setSeatID(int s) {
		seatID = s;
	}
	
	public int getSeatID() {
		return seatID;
	}
	
	/**
	 * Check to see if the user clicked somewhere inside of the valid range
	 * of pixels that this seat is located based on the level of zoom.
	 * If they have clicked on a valid location, then activate this seat.
	 * @param clickedX
	 * @param clickedY
	 * @param zoomLevel
	 * @return
	 */
	public boolean isSelected(float clickedX, float clickedY, float zoomLevel) {
		if (zoomLevel == 1f) {
			if ((clickedX >= range[0] && clickedX < range[0]+17) &&
				(clickedY >= range[1] && clickedY < range[1]+20)) {
				isActive = true;
				return true;
			}
		}
		else if (zoomLevel == 1.5f) {
			if ((clickedX >= range[2] && clickedX < range[2]+27) &&
				(clickedY >= range[3] && clickedY < range[3]+32)) {
				isActive = true;
				return true;
			}
		}
		else if (zoomLevel == 2f) {
			if ((clickedX >= range[4] && clickedX < range[4]+31) &&
				(clickedY >= range[5] && clickedY < range[5]+44)) {
					isActive = true;
					return true;
			}
		}
		else if (zoomLevel == 2.5f) {
			if ((clickedX >= range[6] && clickedX < range[6]+40) &&
				(clickedY >= range[7] && clickedY < range[7]+56)) {
					isActive = true;
					return true;
			}
		}
		return false;
	}
	
	public void setZoomLevel(float z) {
		zoomLevel = z;
	}
}
